-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to react-router@6
#979
base: main
Are you sure you want to change the base?
Conversation
Pushed an update to get SceneAppPage and most demos to work Scene apps needs a big update
|
<Route path={`${ROUTES.Demos}/*`} Component={DemoListPage} /> | ||
<Route path={`${ROUTES.GrafanaMonitoring}/*`} Component={GrafanaMonitoringApp} /> | ||
<Route path={`${ROUTES.ReactDemo}/*`} Component={ReactDemoPage} /> | ||
{/* <Redirect to={prefixRoute(ROUTES.Demos)} /> */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add a v6 redirect here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just make DemoListPage
a fallback page instead?
<Route path="*" Component={DemoListPage} />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's still missing, isn' it?
e85e581
to
65f02c1
Compare
I have spent sometime trying to green out all the test case, and although I think got somewhere, there are some weird things that might need someone with deeper knowledge of the scenes projects. The main issue is with the tests under the scenes package: for some reason the inline @grafana/dashboards-squad |
77516f0
to
8ee5f00
Compare
@leventebalogh I see the tests are passing, did you find the issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @leventebalogh
How does this work for apps built with scenes that run in Grafana? Will they continue to work as long as they are built with an older version of scenes, or will they break when Grafana and scenes runs on router@v6?
Yes, thanks @oscarkilhed, we managed to green them out with @jackw 👍
I am currently testing out these changes with an example plugin, and as soon as I am done with that I'll update the PR description with correct instructions on what steps plugins need to take for updating. (We will probably also have a migration page for this) At the time being Grafana still supports plugins both using react-router@v5 or react-router@v6. This means, that plugins built with an earlier scenes version will still be supported (at least until core is updated to use react-router@v6 fully - then they will break). As far as I know scenes is bundled (and not externalised), so it shouldn't be a problem that core is depending on a different version (for now). I'll double check this though as well, and update the PR description! This must be major version bump though, as any plugins updating to this scenes version will also need to update some things in their source code. |
@leventebalogh do we need any additional steps for this to work in grafana/grafana? Did a draft scenes bump PR to launch a drone pipeline and quite a lot of tests are erroring out 🤔 |
c982524
to
abedd6d
Compare
Thanks @Sergej-Vlasov, nice catch! 🙏 It looks like the issue was that core Grafana had a different version of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leventebalogh great job! This seems to be working now!
Since this is a major release lets postpone the merge a bit to allow any bugfixes/docs to land before hand. You can still start working on updating plugins in the mean time by using canary release of this PR.
We have the release notes with how to handle this breaking change but I think it would also be beneficial to include this in https://grafana.com/developers/scenes/
<Route path={`${ROUTES.Demos}/*`} Component={DemoListPage} /> | ||
<Route path={`${ROUTES.GrafanaMonitoring}/*`} Component={GrafanaMonitoringApp} /> | ||
<Route path={`${ROUTES.ReactDemo}/*`} Component={ReactDemoPage} /> | ||
{/* <Redirect to={prefixRoute(ROUTES.Demos)} /> */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's still missing, isn' it?
@@ -191,6 +194,7 @@ export function getVariablesDemo(defaults: SceneAppPageState) { | |||
new SceneAppPage({ | |||
title: 'Many variable options', | |||
url: `${defaults.url}/many-values`, | |||
routePath: 'many-values', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we shouldn't make routePath
mandatory, since it can be either a fixed string or parametrizable one. And all over the place in this PR the routePath is being added to the app pages. Don't think I saw a single app page in this PR that would not require it. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think that's a good point, I couldn't think of any scenario where it wouldn't be necessary from now on (unless I am missing something). It could also help with migration I think for plugins (showing type errors for wherever it's missing). What do you think @torkelo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dprokop yea, I agree. Should be mandatory
@Sergej-Vlasov Thanks, sure 👍
Yeah, I think adding some migration docs would make sense as well, as this is a bit more "complicated" change, similar to what we have in https://grafana.com/developers/plugin-tools/migration-guides/update-from-grafana-versions/. |
Fixes #608
Updates the scenes packages to use react-router v6.
This probably requires a major version bump, as it's going to be a breaking change for plugins that depend on scenes.
Why?
We are in the process of migrating Grafana core and also internal plugins to use react-router v6, however any plugin that is depending on scenes cannot easily do it (or at least it's a complicated task). Scenes still using react-router v5 is a blocker for plugins that would like to update.
Huge thanks to @jackw for the help of discovering and removing some of the circular dependences in the scenes package that were causing Jest to go mental.
Release notes
This release marks a big change where scene app based routing is using react-router v6 under the hood. This sadly requires several changes to plugins as react-router now requires all route paths to be relative.
Updating a plugin
Example plugin update PR →
@grafana/scenes
react-router-dom
@types/react-router-dom
-"@types/react-router-dom": "^5.2.0",
<Route>
: use relative wildcard routes<Route>
: use theelement
prop<Switch>
: replace withRoutes
routePath
prop to each<SceneAppPage>. It needs to include a wildcard if there are any drill-down or tab pages under it.
routePath
prop defined on drill-downs relative and include a wildcard. **Testing
The following tests were done with a locally built Grafana and new plugin scaffolds.
📦 Published PR as canary version:
6.0.0--canary.979.12746556745.0
✨ Test out this PR locally via: